import { AxiosResponse } from 'axios';
import instance from '../instance';
import { IClearLossRecordData, IDivideRecordData, IFeedLossRecordData, IPutRecordData, IMedicationRecordData, IImmunizationRecordData, IWaterQualityRecordData,IMeteorologyRecordData} from './typing';

function getFeedLossRecordData(data: {
  poolNos?: string[];
  date: string[];
}): Promise<AxiosResponse<IFeedLossRecordData[], any>> {
  return instance.post('/feedLoss/record', data);
}
function getDivideRecordData(data: {
  poolNos?: string[];
  date: string[];
}): Promise<AxiosResponse<IDivideRecordData[], any>> {
  return instance.post('/divide/record', data);
}
function getClearLossRecordData(data: {
  poolNos?: string[];
  date: string[];
}): Promise<AxiosResponse<IClearLossRecordData[], any>> {
  return instance.post('/clearLoss/record', data);
}
function getSaleRecordData(data: {
  poolNos?: string[];
  date: string[];
  saleType: 0 | 1;
}): Promise<AxiosResponse<IFeedLossRecordData[], any>> {
  return instance.post('/sale/record', data);
}
function getPutRecordData(data: { poolNos?: string[]; date: string[] }): Promise<AxiosResponse<IPutRecordData[], any>> {
  return instance.post('/put/record', data);
}
function getMedicationRecordData(data: {
  poolNos?: string[];
  date: string[];
}): Promise<AxiosResponse<IMedicationRecordData[], any>> {
  return instance.post('/medication/record', data);
}

function getImmunizationRecordData(data: {
  poolNos?: string[];
  date: string[];
}): Promise<AxiosResponse<IImmunizationRecordData[], any>> {
  return instance.post('/immunization/record', data);
}
function getWaterQualityRecordData(data: {
  poolNos?: string[];
  date: string[];
}): Promise<AxiosResponse<IWaterQualityRecordData[], any>> {
  return instance.post('/waterQuality/record', data);
}
function getMeteorologyRecordData(data: {
  poolNos?: string[];
  date: string[];
}): Promise<AxiosResponse<IMeteorologyRecordData[], any>> {
  return instance.post('/meteorology/record', data);
}

function addMedicationRecordData(data: {
  poolNo: string;
  userId:string;
  drug:string;
  dosage: number;
  manufacturer: string;
  date: string;
}): Promise<AxiosResponse<IMedicationRecordData[], any>> {
  return instance.post('/medication/add', data);
}

function addImmunizationRecordData(data: {
  poolNo: string;
  userId:string;
  description:string;
  date: string;
}): Promise<AxiosResponse<IImmunizationRecordData[], any>> {
  return instance.post('/immunization/add', data);
}
function addWaterQualityRecordData(data: {
  poolNo: string;
  userId:string;
  temperature:number;
  ph:number;
  conductivity:number;
  oxygen:number;
  turbidity:number;
  level:number;
  date:string;
}): Promise<AxiosResponse<IWaterQualityRecordData[], any>> {
  return instance.post('/waterQuality/add', data);
}
function addMeteorologyRecordData(data: {
  poolNo: string;
  userId:string;
  temperature:number;
  wind:string;
  scale:number;
  weather:string;
  date: string;
}): Promise<AxiosResponse<IMeteorologyRecordData[], any>> {
  return instance.post('/meteorology/add', data);
}

function deleteMedicationRecordData(data: { 
  poolNo: string;
  date:string;
 }) : Promise<AxiosResponse<IMedicationRecordData[], any>> {
  return instance.post('/medication/delete', data);
}


function deleteImmunizationRecordData(data: { 
  poolNo: string;
  date:string;
 }) : Promise<AxiosResponse<IImmunizationRecordData[], any>> {
  return instance.post('/immunization/delete', data);
}


function  deleteWaterQualityRecordData(data: { 
  poolNo: string;
  date:string;
 }) : Promise<AxiosResponse<IWaterQualityRecordData[], any>> {
  return instance.post('/waterQuality/delete', data);
}

function   deleteMeteorologyRecordData(data: { 
  poolNo: string;
  date:string;
 }) : Promise<AxiosResponse<IMeteorologyRecordData[], any>> {
  return instance.post('/meteorology/delete', data);
}
function editMedicationRecordData(data: {
  poolNo: string;
  drug:string;
  dosage: number;
  manufacturer: string;
  date: string;
}): Promise<AxiosResponse<IMedicationRecordData[], any>> {
  return instance.post('/medication/update', data);
}

function editImmunizationRecordData(data: {
  poolNo: string;
  description:string;
  date:string;
}): Promise<AxiosResponse<IImmunizationRecordData[], any>> {
  return instance.post('/immunization/update', data);
}
function editWaterQualityRecordData(data: {
  poolNo: string;
  temperature:number;
  ph:number;
  conductivity:number;
  oxygen:number;
  turbidity:number;
  level:number;
  date:string;
}): Promise<AxiosResponse<IWaterQualityRecordData[], any>> {
  return instance.post('/waterQuality/update', data);
}
function editMeteorologyRecordData(data: {
  poolNo: string;
  temperature:number;
  wind:string;
  scale:number;
  weather:string;
  date: string;
}): Promise<AxiosResponse<IMeteorologyRecordData[], any>> {
  return instance.post('/meteorology/update', data);
}
export default {
  getFeedLossRecordData,
  getDivideRecordData,
  getClearLossRecordData,
  getSaleRecordData,
  getPutRecordData,
  getMedicationRecordData,
  getImmunizationRecordData,
  getWaterQualityRecordData,
  getMeteorologyRecordData,
  deleteMedicationRecordData,
  deleteImmunizationRecordData,
  deleteWaterQualityRecordData,
  deleteMeteorologyRecordData,
  addMedicationRecordData,
  addImmunizationRecordData,
  addWaterQualityRecordData,
  addMeteorologyRecordData,
  editMedicationRecordData,
  editImmunizationRecordData,
  editWaterQualityRecordData,
  editMeteorologyRecordData
};
